<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Index extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->helper('url');
        $this->load->library('session');
    }
    public function index() {
        $this->load->model('News_model');
        $data['index_news'] = $this->News_model->topNews();
        if($this->session->userdata('barangay_id') == '' || $this->session->userdata('barangay_id') == null) {
            $this->load->model('General_model');
            $data['index_brgys'] = $this->General_model->newlyApprovedBarangays();
            $this->load->view('index_main', $data);
        } else {
            $this->load->model('Products_model');
            $data['top_products'] = $this->Products_model->topProducts();
            $this->load->view('index_main', $data);
        }
    }
    public function index1() {
        $this->load->view('index_main');
    }
}